Danyele,
I would not recommend using getCommonUserName. It returns the server when used on a server side script but it's used to return the user running the script, so use session.getServerName() to retrieve the server in a reliable way.
For the error message, is the database you try to open on the same server as the database you run this code ? If yes, you need to check if the server you run this code can access the other server. When you use loutsscript, you have to setup the calling server as a trusted server to allow access using serverside code, so it's probably the same for SSJS code in xpages.
You might look for trusted servers on the admin help to have details about this.
Hope this helps.
Renaud